<{extends file="../layout/layout.phtml"}>
<{block name='content'}>
<link rel="stylesheet" href="/css/admin_product.css">
<div id='admin-product-add'>
	<form id='product_form' method='post' onsubmit='return false;'>
		<div><span>标题：</span><input type="text" name='title'><span class='red'>*</span></div>
		<div><span>链接：</span><input type="text" name='href' placeholder='http://xxx.xxx.xx'><span class='red'>*</span></div>
		<div><span>状态：</span> <input type="radio" name='status' value='1' checked>开启<input type="radio" name='status' value='0'>关闭</div>
		<div><span>标题：</span><input type="text" name='order' placeholder='0~255'></div>
		<input type="hidden" value="<{$id}>" name="_id">
		<div><button id='product-botton'>保存</button> <span id="error_show"></span></div>
	</form>
</div>
<script>
	window.addEvent('domready',function(){
		//登陆ajax
	    var msg_div = $("error_show");
	    var product_request = new Request.JSON({
	        url: '/index.php/admin/product/ajax_add_check',
	        method: 'post',
	        onRequest: function(){
	            msg_div.set('text', 'Loading...');
	        },
	        onSuccess: function(responseJson){
	            msg_div.set('html', responseJson.msg);
	            if(responseJson.flag){
	                location.href='/index.php/admin/product/index';
	            }
	        },
	        onFailure: function(){
	            msg_div.set('text', 'Sorry, your request failed :(');
	        }
	    }); 
	    // and to send it:
	    $("product-botton").addEvent('click',function(){
	        
	        product_request.send($("product_form").toQueryString());
	    })
	})
</script>
<{/block}>